package com.shuyun.springdata.showcase.spesc;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.support.SimpleJpaRepository;

import javax.persistence.EntityManager;
import java.io.Serializable;

/**
 * Created by feng.ding on 2017/1/9.
 */
public class CustomerRepositoryImpl<T, ID extends Serializable>
        extends SimpleJpaRepository<T, ID> implements CustomerRepository<T, ID>{

    private final EntityManager entityManager;

    public CustomerRepositoryImpl(Class<T> example, EntityManager entityManager){
        super(example, entityManager);
        this.entityManager = entityManager;
    }

    @Override
    public Page<T> findByAuto(T example, Pageable pageable) {
        return findAll(CustomerSpecs.byAuto(entityManager, example), pageable);
    }
}
